package com.jinyu.admin.controller.sys;

import cn.dev33.satoken.annotation.SaCheckPermission;
import com.jinyu.admin.service.sys.SysMenuService;
import com.jinyu.common.base.ApiRestResponse;
import com.jinyu.dao.entity.sys.SysMenu;
import jakarta.validation.Valid;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author: yangli
 * @Despriction:    菜单模块
 * @Package: com.jinyu.admin.controller.sys
 * @Date:Created in 2022/5/7 21:53
 * @Modify By:
 */
@Slf4j
@RestController
@RequestMapping("/menu")
public class SysMenuController {

    @Autowired
    private SysMenuService sysMenuService;

    /**
     *  新增菜单接口
     * @param sysMenu   菜单数据
     * @return  ApiRestResponse
     */
    @SaCheckPermission(value = "ADD",orRole = {"super_admin","admin"})
    @PostMapping("/addMenu/1.0")
    public ApiRestResponse<Object> addMenu (@RequestBody @Valid SysMenu sysMenu) {
        log.info("字典数据信息{}",sysMenu.toString());
        int insert = sysMenuService.insert(sysMenu);
        return insert > 0 ? ApiRestResponse.ok("新增菜单成功") : ApiRestResponse.err("新增菜单失败");
    }
}
